﻿///TODO:
using System;

namespace Pandora.Development.Install
{
    /// <summary>
    /// TODO:
    /// </summary>
    public class WxsPreprocessorExtension : Microsoft.Tools.WindowsInstallerXml.PreprocessorExtension
    {
        #region -- Constants -----------------------------------------------------------------------
        private const string PREFIX_EVAL = "eval";
        #endregion ---------------------------------------------------------------------------------

        private static readonly string[] _Prefixes =
        {
            WxsPreprocessorExtension.PREFIX_EVAL
        };

        /// <summary>
        /// TODO:
        /// </summary>
        public override string[] Prefixes
        {
            get
            {
                return _Prefixes;
            }
        }

        /// <summary>
        /// TODO:
        /// </summary>
        /// <param name="prefix"></param>
        /// <param name="name"></param>
        /// <returns></returns>
        public override string GetVariableValue(string prefix, string name)
        {
            if (prefix == WxsPreprocessorExtension.PREFIX_EVAL)
            {
                //TODO:Replace switch with my own evaluator, that parses lambda expression using my own parser.
                switch (name.ToLower())
                {
                    case "version":
                        return Pandora.Version.Number;
                    default:
                        throw new Exception("Unknown evaluation");
                }
            }

            return base.GetVariableValue(prefix, name);
        }
    }
}
